﻿package cerna_pairs;

public class Jiecheng {
	// 
	private int N;
	private int n;
	private double jieguo;
	// 两种构造方法，一个用来计算阶乘 1 ~ N
	public void Jiecheng (int N){
		this.N = N;
		this.jieguo = jiecheng(N);
	}
	// 计算N ~ (N-n)之间的阶乘
	public void Jiecheng (int N, int n){
		this.N = N;
		this.n = n;
		this.jieguo = jiecheng(N, n);
	}
	private static double jiecheng(int N){
		double num = N;
		if(num > 0){
			return num * jiecheng(N - 1);
		}else{
			return 1;
		}
	}
	
	private static double jiecheng(int N, int n){
		double num = N;
		if((n + 1) > 0){
			return num * jiecheng(N - 1, n - 1);
		}else{
			return 1;
		}
	}
	
	public double get_jiecheng(){
		return this.jieguo;
	}
}
